package com.itheima.dfs.template;

import com.itheima.dfs.enums.DFSType;
import org.springframework.beans.factory.InitializingBean;

import java.util.Arrays;
import java.util.function.Predicate;

/**
 * @version 1.0
 * @description 说明
 * @package com.itheima.dfs.template
 */
public abstract class AbstractDfsTemplate implements DfsTemplate, InitializingBean {

    /**
     * 定义支持的类型 必须设置值
     *
     * @return
     */
    public abstract DFSType support();

    @Override
    public void afterPropertiesSet() throws Exception {
        DFSType[] values = DFSType.values();
        DFSType support = support();
        if(!Arrays.stream(values).anyMatch(Predicate.isEqual(support))){
            throw new java.lang.RuntimeException("不支持的dfs类型");
        }
    }
}